package com.taobao.sinan.dal.manager;

import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;

import com.taobao.sinan.dal.App;

public class AppManager {
	private static final AppManager instance = new AppManager();
	private Map<String, App> apps = new TreeMap<String, App>();

	private AppManager() {

	}

	public static AppManager getInstance() {
		return instance;
	}

	public App getAppByName(String name) {
		return apps.get(name);
	}

	public Collection<App> getAllApp() {
		return apps.values();
	}

	public boolean addApp(App app) {
		if (apps.containsKey(app.getName())) {
			return false;
		} else {
			apps.put(app.getName(), app);
			return true;
		}
	}
}
